package com.qfedu.proxy;

public class MyStaicProxy {
    private GenderDAO gregorian;

    public MyStaicProxy(GenderDAO gregorian) {
        this.gregorian = gregorian;
    }

    public void insert() {
        begin();
        gregorian.insert();
        commit();
    }

    public void detele() {
        begin();
        gregorian.detele();
        commit();
    }

    public void update() {
        begin();
        gregorian.update();
        commit();
    }

    long time1;
    long time2;

    public void  begin(){
        time1 = System.currentTimeMillis();
        System.out.println("---开启事务");
    }
    public void  commit(){
        System.out.println("---提交事务");
        time2 = System.currentTimeMillis();
        System.out.println(gregorian.getClass() +"执行时间" + (time2 - time1));
    }
}
